package com.huluobo.mvvm_base.viewmodel;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;

import com.huluobo.mvvm_base.model.BaseRepo;

/**
 * Created by LC on 2023/11/30.
 * Repo 所有继承过BaseRepo的数据仓库类
 * createRepo 所有继承子BaseViewModel 的类都需要实现的方法
 * 返回值是一个具体的数据仓库,他需要new才能使用,所以继承的子类必须要实现
 */
public abstract class BaseViewModel<Repo extends BaseRepo> extends AndroidViewModel {
    protected Application application;

    protected Repo repo;

    public BaseViewModel(@NonNull Application application) {
        super(application);
        this.application = application;
        repo = createRepo();
    }

    protected abstract Repo createRepo();

}
